	<?php $html->css('/events/css/events.css',null,array(),false);?>

<div class="events form">
<?php
	$html->addJUI();
	echo $form->create('Event',array('url'=>'/'.$this->params['url']['url'],'type'=>'file'));
	$assetsAddHtml = $form->input("asset_inputs");
	ob_start();
	$form->defaultEmpty = __("-Select-");
	echo "<div id=\"event_fields_input\">";
	//echo $this->element('event_add_form_fields',array('eventDefaultFields'=>$eventDefaultFields));
	//echo $form->inputs(array('fieldset'=>false), null, 'add');
	$fields = cri("Events.Event")->getFields("group","add");
	$eventCostFieldsFlag = false;
	foreach ($fields as $field)
	{
		echo $eventForm->showInputField($form,$field);
	}
	
	echo "</div>";
	$infoFields = ob_get_clean();
	$tabsHtml = array();
	$tabsHtml[] = array(__("Main Information"),$infoFields,array("container_id"=>"main_info"));
	$infoFields = "";

	$imagesContent = "";
	if($showImageTab)
	{
		ob_start();
		?>
		<div>
		<?php echo $this->element('assets_on_edit_page');?>
			<div>
			<?php echo $assetsAddHtml; ?>
			</div>
		</div>
		<?php
		$imagesContent = ob_get_clean();
		$tabsHtml[] = array(__("Images"),$imagesContent,array("container_id"=>"images_content"));
	}

	if(count($tabsHtml) > 1)
	{
		foreach($tabsHtml as $tab)
		{
			call_user_func_array(array($tabs,'addtab'), $tab);
		}
		echo $tabs->show();
	} else {
		echo $tabsHtml[0][1];
		echo $imagesContent;
	}
	echo $form->end(__("Save"));
?>
</div>
<script>
	if ($("#EventIsFree").attr('checked'))
	{
		document.getElementById('EventEventCost').disabled = true;
		document.getElementById('EventEventCostTo').disabled = true;
	}

	/*
	$(document).ready(function(){
		$('#EventListingText').autocomplete("<?php //echo $html->url("/events/events/suggestListings/") ?>",{
			minChars: 2,
			//cacheLength: 10,
			onItemSelect: selectItem,
			//autoFill: false
		});
	});
	*/

	function selectItem(li) 
	{
		var sValue = null;	 
	    if( li == null ) 
		{
	    	sValue = null;
		} else {
		    if( !!li.extra )
		    {
			    sValue = li.extra[0];
		    }
		}
		document.getElementById('EventListingId').value=sValue;
	}
</script>